// never 的
import { useLocation } from 'react-router-dom';

import type { LocationState } from './location';
interface Foo {
  type: 'foo';
}

interface Bar {
  type: 'bar';
}

interface Baz {
  type: 'baz';
}

type All = Foo | Bar | Baz;

function handleValue(val: All) {
  switch (val.type) {
    case 'foo':
      // 这里 val 被收窄为 Foo
      break;
    case 'bar':
      // val 在这里是 Bar
      break;
    case 'baz':
      // val 在这里是 Baz
      break;
    default:
      // val 在这里是 never
      const exhaustiveCheck: never = val;
      break;
  }
}

export const App3 = () => {
  // 获取location信息
  const location = useLocation<LocationState | undefined>();
  console.log('app2 location', location.state);
  console.log('app2 location', location.state?.from);

  // 获取是怎么到组件3

  return <div>App3</div>;
};
